package org.swfer.UIC 
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	
	/**
	 * 任意属性注入。丑陋复杂的设计
	 * @author swfer
	 * @param	view
	 * @param	attrStruct
	 */
	public function injectMx(view:DisplayObjectContainer,attrStruct:Object):void
	{
		for (var name:String in attrStruct) 
		{
			var component:DisplayObject;
			
			if (name.indexOf('@')!=-1)
			{
				//超级注入
				var arr:Array = name.split('@');
				var objName:String = arr[0];
				var attrName:String = arr[1];
				
				component = view.getChildByName(objName);
				
				if (component && component.hasOwnProperty(attrName))
				{
					component[attrName] = attrStruct[name];
				}
			}
			else
			{
				//普通注入
				component = view.getChildByName(name);
				if (component && component.hasOwnProperty('text')) 
				{
					component['text'] = attrStruct[name];
				}
			}
		}
	}

}